package tomsung.cloud.agdc.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tomsung.cloud.agdc.bean.BeamStrength;
import tomsung.cloud.agdc.dao.BeamStrengthMapper;

@Service("BeamStrengthService")
public class BeamStrengthService {

	@Autowired
	BeamStrengthMapper beamStrengthMapper;
	
	public synchronized int createBeamData(BeamStrength record)
	{
		return beamStrengthMapper.insertSelective(record);
	}
	
	public int deleteBeamData(Integer groupid)
	{
		return beamStrengthMapper.deleteByPrimaryKey(groupid);
	}
	
	public BeamStrength selectBeamData(Integer groupid)
	{
		return beamStrengthMapper.selectByPrimaryKey(groupid);
	}
	
	public int updateBeamStrengthData(BeamStrength record)
	{
		return beamStrengthMapper.updateByPrimaryKey(record);
	}
	
	public List<BeamStrength> selectBeamStrengthBySystemId(List<Long> systemIds, Date beginTime, Date endTime)
	{
		List<BeamStrength> beamStrengths = new ArrayList<BeamStrength>();
		for (Long id : systemIds)
		{
			List<BeamStrength> beams = beamStrengthMapper.getBeamStrengthBySystemId(id, beginTime, endTime);
			if (beams != null && beams.size() > 0)
			{
				beamStrengths.addAll(beams);
			}
		}
		return beamStrengths;
	}
}
